package package2;

/*
 *  user:38917
 *  date:2025/5/3
 *  time:19:28
 */

public class Student {
    public String name;
    public int age;
    //静态代码块1
    static {
        classroom = "100";
        System.out.println("静态代码块1执行");
    }
    //静态代码块2
    static {
        classroom = "200";
        System.out.println("静态代码块2执行");
    }
    //静态成员变量
    public static String classroom = "300";
    //构造方法
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
    //
    public void print(){
        System.out.println(name + " " + age);
    }
    //静态方法
    public static String getClassroom(){
        return classroom;
    }
    //实例代码块
    {
        this.name = "八戒";
        this.age = 1000;
    }
}
class Test{
    public static void main(String[] args) {
        Student student1 = new Student("张三",18);
        student1.print();
        Student student2 = new Student("李四",19);
        student2.print();
        System.out.println(Student.classroom);
    }
}